package study.dubbo.springcloud.provider.service;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;
import study.dubbo.api.service.ServerService;

import java.net.InetAddress;
import java.util.Map;

@Slf4j
@Component
@DubboService
public class ServerServiceImpl implements ServerService {

    @Override
    public Map<String, Object> getServerInfo() {
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        String host = address.getHostAddress();

        Map<String, Object> data = Maps.newHashMap();
        data.put("host", host);
        return data;
    }
}
